{% extends "base.html" %}
{% load promgen %}
{% load tz %}
{% block content %}
<div class="page-header">
  <h1>Log</h1>
</div>

{% if request.GET %}
<ul class="list-inline" v-pre>
  <li>Filters</li>
{% for k in request.GET %}
<li>
  <a
    class="btn btn-danger btn-xs"
    href="{% url 'audit-list' %}?{% qs_replace k None %}"
    >{{k}} &times;</a>
{% endfor %}
</ul>
{% endif %}

<div class="panel panel-default" v-pre>
    <table class="table table-bordered table-condensed" style="table-layout: fixed;">
      <thead>
        <tr>
          <th class="col-md-1">Timestamp</th>
          <th class="col-md-1">User</th>
          <th class="col-md-6">Body</th>
          <th class="col-md-3">Link</th>
        </tr>
      </thead>
{% for entry in audit_list %}
      <tr class="{{ entry.highlight }}">
        <td>{{ entry.created|timezone:TIMEZONE }}</td>
        <td style="word-break: break-word">
          <a href="{% url 'audit-list' %}?{% qs_replace 'user' entry.user.id %}">{{ entry.user }}</a>
        </td>
        <td style="word-break: break-all">
          {{ entry.body }}

          {% if entry.data %}
          <br />
          <a data-toggle="collapse" href="#collapse-log-{{entry.id}}" aria-expanded="false" aria-controls="collapseExample">
            Show
          </a>
          <div class="collapse" id="collapse-log-{{entry.id}}">
            {% if entry.old %}
            <pre>{% diff_json entry.old entry.data %}</pre>
            {% else %}
            <pre>{{ entry.data|pretty_json}}</pre>
            {% endif %}
          </div>
          {% endif %}
        </td>
        <td style="word-break: break-all">{% audit_log_link entry %}</td>
      </tr>
{% endfor %}
    </table>
</div>

{% include 'promgen/pagination_short.html' %}

{% endblock %}
